package terra;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Properties;

public final class NetworkConfig
{
	public static int port = 9088;
	public static String hostName = "localhost";
	public static boolean tcpNoDelay = true;
	public static int receiveBufferSize = 8192;
	public static int sendBufferSize = 8192;
	
	public static void loadConfig()	{
		Properties prop = new Properties();
		try {
			File f = new File("netconfig.ini");
			InputStream input = null;
			if (!f.exists()){
				input = Config.class.getResourceAsStream("netconfig.ini");
			} else
				input = new FileInputStream(f);
			prop.load(input);
			//System.out.println(f.getAbsolutePath());
			System.out.println(prop.toString());
		} catch (Exception e){
			e.printStackTrace();
		}
		port =  Integer.parseInt(prop.getProperty("port", "9088"));
		tcpNoDelay =  Boolean.parseBoolean(prop.getProperty("tcpNoDelay", "true"));
		hostName = prop.getProperty("hostName", "localhost");
		sendBufferSize = Integer.parseInt(prop.getProperty("sendBufferSize", "8192"));
		receiveBufferSize = Integer.parseInt(prop.getProperty("receiveBufferSize", "8192"));
		//System.out.println("networkConfig loaded");
		//System.out.println("hostName : "+hostName);
		//System.out.println("port : "+port);
	}
}
